[mirrors]
http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.20.tar.gz
http://files.directadmin.com/services/all/mysql/mysql-5.6.20.tar.gz

[vars]
filesize=32979820
sha512=c4bcc2a209616a38c04a4679cc7a76b354f0d7d3dda860b82b9cdb4746f897aa5c8204a440e1c65f55d81b2ac526b205dd0ba28786ba21778cc068efd71403ac


[deps.host]
cmake

[deps]
curses
readline

[build]
patch -p1 < "$K"/mysql-srv_buf_size.patch
sed -i '/OPENSSL_MAJOR_VERSION/s/1/2/' cmake/ssl.cmake

# prevent installation of 10K tests, 180MB, + and additional 35MB of symlinks
DISABLE_TESTS=true
if $DISABLE_TESTS ; then
	echo "RETURN()" > tests/CMakeLists.txt
	echo "RETURN()" > libmysqld/examples/CMakeLists.txt
	sed -i 's@  ADD_SUBDIRECTORY(tests)@@' CMakeLists.txt
	sed -i 's@  ADD_SUBDIRECTORY(mysql-test)@@' CMakeLists.txt
	sed -i 's@  ADD_SUBDIRECTORY(mysql-test/lib/My/SafeProcess)@@' CMakeLists.txt
	rm -rf tests mysql-test
fi

mkdir build && cd build


CC="$CC -DTHD_LIB_LT=1 -Dthd_lib_detected=2" cmake \
  -DCMAKE_INSTALL_PREFIX=$butch_prefix \
  -DINSTALL_DOCDIR=share/doc/mysql \
  -DINSTALL_DOCREADMEDIR=share/doc/mysql \
  -DINSTALL_INCLUDEDIR=include/mysql \
  -DINSTALL_INFODIR=share/info \
  -DINSTALL_MANDIR=share/man \
  -DINSTALL_MYSQLDATADIR=$butch_prefix/srv/mysql \
  -DINSTALL_MYSQLSHAREDIR=share/mysql \
  -DINSTALL_MYSQLTESTDIR=share/mysql/test \
  -DINSTALL_PLUGINDIR=lib/mysql \
  -DINSTALL_SBINDIR=sbin \
  -DINSTALL_SCRIPTDIR=bin \
  -DINSTALL_SQLBENCHDIR=share/mysql/bench \
  -DINSTALL_SUPPORTFILESDIR=share/mysql/support \
  -DMYSQL_DATADIR=/srv/mysql \
  -DMYSQL_UNIX_ADDR=/var/run/mysql/mysql.sock \
  -DSYSCONFDIR=/etc \
  -DWITH_PARTITION_STORAGE_ENGINE=OFF \
  -DWITH_PERFSCHEMA_STORAGE_ENGINE=OFF \
  -DWITH_ATOMIC_LOCKS=ON \
  -DWITH_SSL=system \
  -DWITH_ZLIB=system \
  -DWITH_PIC=ON \
  -DENABLE_PROFILING=OFF \
  -DWITH_DEBUG=OFF \
  -DWITH_UNIT_TESTS=OFF \
  -DMANUFACTURER=YourMOM \
  -DWITH_EXTRA_CHARSETS=none \
  -DCMAKE_BUILD_TYPE=MinSizeRel \
  -DCMAKE_C_FLAGS="-D__STDC_ISO_10646__ -DSHM_R=0400 -DSHM_W=0400" \
  -DWITH_READLINE=OFF \
  -DWITH_LIBEDIT=system \
  -DDEFAULT_MYSQL_HOME="/" \
  -DDEFAULT_CHARSET_HOME="/" \
  -DCMAKE_EXE_LINKER_FLAGS="-lterminfo $optldflags" \
      ..

CC="$CC -DTHD_LIB_LT=1 -Dthd_lib_detected=2" make -j$MAKE_THREADS VERBOSE=1

#  -DWITH_READLINE=OFF \
#  -DWITH_LIBEDIT=system \

# possible CMAKE_BUILD_TYPEs: Debug, Release, RelWithDebInfo and MinSizeRel

make DESTDIR="$butch_install_dir" install
